//---------------Sonic CD Special Setup Script----------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

// Aliases

// Universal
private alias Object.Value5 : Object.ScreenDepth

// HUD Alias
private alias Object.Value0 : HUD.UFOsCount
private alias Object.Value1 : HUD.TimeSeconds
private alias Object.Value2 : HUD.TimeFrames
private alias Object.Value6 : HUD.BonusUFONo // "No" akin to Entity No, not as in "is there no UFO?"
private alias Object.Value7 : HUD.WaterTimer

// UFO Alias
private alias Object.YPos : Object.ZPos

private alias Object.Value3 : rain.scroll
// SSSonic Aliases
private alias object.controlmode : SSSonic.ControlMode

// ControlMode Aliases
private alias -1 : CONTROLMODE_NONE

// Stage Finish State Aliases
private alias 9 : STAGEFINISH_LOADLEVELSELECT

// Game Mode Aliases
private alias 2 : MODE_TIMEATTACK

// Stage SFX
private alias 5 : SFX_S_TIMEUFO
private alias 7 : SFX_S_DROWNALERT

// Soundtrack
private alias 0 : OST_JP

// Priority
private alias 1 : PRIORITY_ACTIVE

// Tile Layer Types
private alias 4 : LAYER_3DSKY

private alias object.value2 : bg.scroll


event ObjectMain
	if PlayerDied == 1
		object.value0++
		if object.value0 >= 150
			object.alpha += 2
		end if
		if Delta_Activate == 1
			music.volume = 0
		end if
	end if
end event


event ObjectDraw

	if PlayerDied == 1
		object.InkEffect = INK_ALPHA
		object[2].visible = 0
		bg.scroll++
		bg.scroll &= 127
		temp0 = bg.scroll
		FlipSign(temp0)
		while temp0 < screen.ysize
			temp1 = bg.scroll
			FlipSign(temp1)
			while temp1 < screen.xsize
				DrawSpriteScreenFX(10, FX_INK, temp1, temp0)
				temp1 += 128		
			loop
			temp0 += 128
		loop	

		DrawSpriteScreenFX(0, FX_SCALE, screen.xcenter, screen.ycenter)		
		object.scale = 2048
		object.scale += 2
	end if

end event


event ObjectStartup
	
	// Despite not having any SpriteFrames to draw with, go ahead and load the Special Stage objects sheet anyway
	// (It doesn't make much of a difference but hey, may as well anyway!)
	LoadSpriteSheet("3D_Test/Objects.gif")
	
	// 0 - SLENDERMAN!!
	SpriteFrame(-32, -24, 63, 112, 339, 1)


	SpriteFrame(-34, -30, 68, 30, 0, 412) //1 Static
	SpriteFrame(-34, -30, 68, 30, 0, 442)//2
	SpriteFrame(-34, -30, 68, 30, 0, 472)//3
	SpriteFrame(-34, -30, 68, 30, 68, 412)//4
	SpriteFrame(-34, -30, 68, 30, 68, 442)//5
	SpriteFrame(-34, -30, 68, 30, 68, 472)//6
	SpriteFrame(-34, -30, 68, 30, 136, 412)//7
	SpriteFrame(-34, -30, 68, 30, 136, 442)//8
	SpriteFrame(-34, -30, 68, 30, 136, 472)//9


	SpriteFrame(0, 0, 128, 128, 574, 308) //33


	Object[35].Type = TypeName[Death Event]
	Object[35].Priority = PRIORITY_ACTIVE


	// Give it a draw order lower right before the primary one, to make sure it can sort all the upcoming 3d entities correctly
	Object[35].DrawOrder = 6

	
end event


// ========================
// Editor events
// ========================

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143) // "Script" Box

	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
